// part1:C10:ex10.35.cpp
// use iterator to reverse a vector.
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[]) {
  if (argc != 2) {
    cout << "usage:execise.txt in_file!" << endl;
    return -1;
  }

  ifstream in(argv[1]);
  if (!in) {
    cout << "failed open input file!" << endl;
    exit(1);
  }

  vector<int> vi;
  int v;
  while (in >> v) {
    vi.push_back(v);
  }

  for (auto r_iter = vi.cend(); r_iter != vi.begin();) {
    cout << *(--r_iter) << " ";
  }
  cout << endl;

  return 0;
}

